/**
 * 刷新关闭窗口
 * @return
 */
function refreshwindows() {
    parent.location.replace(parent.location.href);
    window.close()
}
function creathtml(str) {
    $("#floatBoxBg").hide();
    $("#floatBox").hide()
}
function addpicipnput(filename, inputnameID, iframename) {
    var picid = $('input:[name="picid"]').val();
    var picidhow = $('input:[name="picidhow"]').val();
    var nowid = Number(picid) + 1;
    var picidhowid = Number(picidhow) + 1;
    var hreftxt = '<li id="addsrc_pic' + nowid + '"><a title="' + addbottonname + '" onclick="javascript:parent.windowsdig(\'' + imagestitle + '\',\'iframe:index.php?archive=filemanage&action=filemanage&listfunction=filelist&filetype=img&checkfrom=function&fileinputid=pic' + nowid + '&iframename=' + iframename + '\',\'900px\',\'480px\',\'iframe\')" href="#body">';
    var src_txt = hreftxt + '<img src="templates/images/pic.png" width="100" height="100"></a></li>';
    var input_txt = '<input type="hidden" name="pic[]" id="pic' + nowid + '" size="40" maxlength="50" class="infoInput"/>';
    var images = adminurl + filename;
    var imagedid = '#addsrc_' + inputnameID;
    var nowimages = '<li id="addsrc_pic' + picid + '" ondblclick="javascript:delpicinput(' + picid + ');"><img src="' + images + '" onclick="javascript:addshowpic(\'' + filename + '\');" title="' + remimages + '" width="100" height="100"></li>';
    $(imagedid).remove();
    $("#addpiclist").append(nowimages + src_txt);
    $("#picinputlist").append(input_txt);
    $('input:[name="picid"]').val(nowid);
    $('input:[name="picidhow"]').val(picidhowid)
}
function addshowpic(filename) {
    document.getElementById('showpic').value = filename
}
function delpicinput(picid) {
    var imageid = '#addsrc_pic' + picid;
    var inputid = '#pic' + picid;
    $(imageid).remove();
    $(inputid).remove();
    var picidhow = $('input:[name="picidhow"]').val();
    var picidhow = Number(picidhow) - 1;
    $('input:[name="picidhow"]').val(picidhow)
}
function sessionimg() {
    var imgtitle = '../public/seccode.php?secode=ecisp_seccode&' + Math.random();
    $("#seccodesrc").attr("src", 
    function() {
        return imgtitle
    })
}
/**
 * 登陆表单验证函数
 * @param formData
 * @param jqForm
 * @param options
 * @return
 */
function loginform(formData, jqForm, options) {
    var queryString = $.param(formData);
    var get = urlarray(queryString);
    var um = document.getElementById("logintitle");
    if (get['username'] == "") {
        um.innerHTML = adminuser_login_incorrect;
        document.loginform.username.focus();
        return false
    }
    if (get['username'].match(/^[a-zA-Z]{1}[a-zA-Z0-9]{4,19}$/ig) == null) {
        um.innerHTML = adminuser_login_incorrect;
        document.loginform.username.focus();
        return false
    }
    if (get['password'].length < 6) {
        um.innerHTML = adminuser_login_incorrect;
        document.loginform.password.focus();
        return false
    }
    if (get['password'] == '') {
        um.innerHTML = adminuser_login_incorrect;
        document.loginform.password.focus();
        return false
    }
    if (get['seccode'] == '' || get['seccode'].length < 4) {
        um.innerHTML = adminuser_login_seccode_error;
        document.loginform.seccode.focus();
        return false
    }
}
/**
 * 登陆成功以后返回调用的函数
 * @param options 返回的参数
 * @return 登陆成功转向后台地址mangercenter
 */
function loginformsave(options) {
    var um = document.getElementById("logintitle");
    if (options == 'seerr') {
        um.innerHTML = adminuser_login_seccode_error;
        sessionimg();
        return false
    } else if (options == 'passerr') {
        um.innerHTML = adminuser_login_incorrect;
        sessionimg();
        return false
    } else if (options == 'true') {
        location.href = 'index.php?archive=management&action=tab&loadfun=mangercenter';
        return false
    } else if (options == 'cookerr') {
        um.innerHTML = ie_cookie_err;
        sessionimg();
        return false
    }
}
function ondisplay(div, style) {
    $('#' + div).removeClass().addClass(style)
}
function windowsclass(clikeclass, opendivclass, clikeclass02, opendivclass02, vallist, taplen, stylename, overstylename) {
    $(clikeclass).removeClass(overstylename).addClass(stylename);
    $(opendivclass).show();
    var openid = '';
    var opendivid = '';
    for (i = 1; i <= taplen; i++) {
        if (i != vallist) {
            openid = openid + '#' + clikeclass02 + i + ',';
            opendivid = opendivid + '#' + opendivclass02 + i + ','
        }
    }
    openid = openid + '#neiow';
    opendivid = opendivid + '#neiow';
    $(opendivid).hide();
    $(openid).removeClass(stylename).addClass(overstylename)
}
function onaletdoc() {
    var lastTab = $(".tab_pages").children('div').children('ul').children('li').filter(".tab_selected");
    var nowTAB = lastTab.attr('id');
    var lastDIV = $("#jerichotab_contentholder").children('div').filter(".curholder");
    var nowDIV = lastDIV.attr('id');
    if (nowTAB == "jerichotab_0") return true;
    var topTab = $("#" + nowTAB).prev().filter("li");
    var topTab2 = topTab.attr('id');
    var topDIV = $("#" + nowDIV).prev().filter("div");
    var topDIV2 = topDIV.attr('id');
    var iframename = nowDIV.replace("holder", "iframe");
    self.frames[iframename].location = 'javascript:false';
    $("#" + nowTAB).remove();
    $("#" + nowDIV).remove();
    $("#" + topTab2).removeClass('tab_unselect').addClass('tab_selected');
    $("#" + topDIV2).removeClass('holder').addClass('curholder').css({
        'display': 'block'
    })
}
function onbotton(title, linkurl, closeble, tabFirer, iframename) {
    if (!tabFirer) {
        tabFirer = this
    } else if (iframename) {
        tabFirer = self.frames[iframename].document.getElementById(tabFirer)
    } else {
        tabFirer = tabFirer
    }
    $.fn.jerichoTab.addTab({
        tabFirer: $(tabFirer),
        title: title,
        closeable: closeble,
        iconImg: 'templates/images/tab.gif',
        data: {
            dataType: 'iframe',
            dataLink: linkurl
        }
    }).showLoader().loadData()
}
function ontitlere(str) {
    $(document).attr("title", str)
}
function select_All(checked, formname, bottonname, checkname) {
    var bootkey = true;
    if (document.getElementById(bottonname)) {
        var um = document.getElementById(bottonname);
        var umHTML = null
    } else {
        bootkey = false
    }
    var formlist = document.getElementById(formname);
    for (var i = 0; i < formlist.length; i++) {
        if (formlist.elements[i].name != 'allbox') formlist.elements[i].checked = checked
    }
    if (checked == true) {
        if (bootkey) {
            um.innerHTML = "取消";
            umHTML = "javascript:select_change(false,'" + formname + "','" + bottonname + "','" + checkname + "')";
            $("#" + bottonname).removeAttr("href").attr("href", umHTML)
        }
    } else {
        if (bootkey) {
            um.innerHTML = "全选";
            umHTML = "javascript:select_change(true,'" + formname + "','" + bottonname + "','" + checkname + "')";
            $("#" + bottonname).removeAttr("href").attr("href", umHTML)
        }
    }
    document.getElementById(checkname).checked = checked
}
function select_change(checktype, formname, bottonname, checkname) {
    var bootkey = true;
    if (document.getElementById(bottonname)) {
        var um = document.getElementById(bottonname);
        var umHTML = null
    } else {
        bootkey = false
    }
    if (checktype == true) {
        if (bootkey) {
            um.innerHTML = "取消";
            umHTML = "javascript:select_change(false,'" + formname + "','" + bottonname + "','" + checkname + "')";
            $("#" + bottonname).removeAttr("href").attr("onclick", umHTML)
        }
        select_All(true, formname, bottonname, checkname)
    } else {
        if (bootkey) {
            um.innerHTML = "全选";
            umHTML = "javascript:select_change(true,'" + formname + "','" + bottonname + "','" + checkname + "')";
            $("#" + bottonname).removeAttr("href").attr("onclick", umHTML)
        }
        select_All(false, formname, bottonname, checkname)
    }
}
function select_ok(formname, bottonname, checkname) {
    var bootkey = true;
    if (document.getElementById(bottonname)) {
        var um = document.getElementById(bottonname);
        var umHTML = null
    } else {
        bootkey = false
    }
    if (document.getElementById(checkname).checked == true) {
        if (bootkey) {
            um.innerHTML = "取消";
            umHTML = "javascript:select_change(false,'" + formname + "','" + bottonname + "','" + checkname + "')";
            $("#" + bottonname).removeAttr("href").attr("href", umHTML)
        }
        select_All(true, formname, bottonname, checkname)
    } else {
        if (bootkey) {
            um.innerHTML = "全选";
            umHTML = "javascript:select_change(true,'" + formname + "','" + bottonname + "','" + checkname + "')";
            $("#" + bottonname).removeAttr("href").attr("href", umHTML)
        }
        select_All(false, formname, bottonname, checkname)
    }
}
function count_checked_items(formname) {
    var number_checked = 0;
    var formlist = document.getElementById(formname);
    for (var i = 0; i < formlist.length; i++) {
        if (formlist.elements[i].checked == true) number_checked++
    }
    return number_checked
}
/**
 * 弹出框控制操作
 * @param geturl     需要操作的地址例如：index.php?archive=ordermain&action=setting
 * @param valuename  列表多选框名字，用于取得ID，例如文章ID等。
 * @param valtype     是否需要更新操作
 * @param upvaluename 需要更新操作的字段
 * @param value       需要更新操作字段的值
 * @param loadurl   操作过程的等待
 * @param msgok    确认操作时的提示
 * @param msgerr   确认操作失败时的提示
 * @param retmess  完成后是否刷新页面
 * @param runok   成功时的提示
 * @param runno  失败时的提示
 * @param formname
 * @param bottonname
 * @param checkname
 * @return
 */
function callrun(geturl, valuename, valtype, upvaluename, value, loadurl, msgok, msgerr, retmess, runok, runno, formname, bottonname, checkname) {
    if (count_checked_items(formname) > 0) {
        if (confirm(msgok)) {
            parent.windowsdig('Loading', 'iframe:' + loadurl, '400px', '180px', 'iframe', false);
            var valuearray = "";
            $('input[name="' + valuename + '"]:checked').each(function() {
                valuearray += $(this).val() + ','
            });
            if (valtype == true) {
                valuearray += '&value=' + value + '&dbname=' + upvaluename
            }
            $.ajax({
                type: "POST",
                url: geturl,
                data: valuename + "=" + valuearray,
                success: function(data) {
                    parent.closeifram();
                    refresh(formname, bottonname, checkname);
                    if (retmess == true) {
                        if (data == 'true') {
                            refresh(formname, bottonname, checkname);
                            alert(runok)
                        } else {
                            alert(runno)
                        }
                    } else {
                        if (data == 'true') {
                            refresh(formname, bottonname, checkname)
                        }
                    }
                }
            })
        }
    } else {
        alert(msgerr)
    }
}
function sortinput(geturl, loadurl, msgok, retmess, runok, runno, formname, bottonname, checkname, inputname1, inputname2) {
    if (confirm(msgok)) {
        parent.windowsdig('Loading', 'iframe:' + loadurl, '400px', '180px', 'iframe', false);
        inputname1 = inputname1 == null ? 'infoid': inputname1;
        inputname2 = inputname2 == null ? 'pid': inputname2;
        var idvalue = "";
        var pidvalue = "";
        $('input[name="' + inputname1 + '"]').each(function() {
            idvalue += $(this).val() + ','
        });
        $('input[name="' + inputname2 + '"]').each(function() {
            pidvalue += $(this).val() + ','
        });
        var valuearray = 'infoid=' + idvalue + '&pid=' + pidvalue;
        $.ajax({
            type: "POST",
            url: geturl,
            data: valuearray,
            success: function(data) {
                parent.closeifram();
                if (retmess == true) {
                    if (data == 'true') {
                        refresh(formname, bottonname, checkname);
                        alert(runok)
                    } else {
                        alert(runno)
                    }
                } else {
                    if (data == 'true') {
                        refresh(formname, bottonname, checkname)
                    }
                }
            }
        })
    }
}
function GP_popupConfirmMsg(msg) {
    document.MM_returnvalue = confirm(msg)
}
function pagewindow() {
    var h = $(window).height();
    var pageh = h - 110;
    var pagemax = Math.round((pageh) / 32);
    if (pagemax <= 0) {
        pagemax = 1
    }
    return pagemax
}
/**
 * @param botid 组合ID用的前一部分，例如id="ordertype0"， botid就是"ordrtype"
 * @param string php页面接收参数的名字 比如订单类型 "ordertype"
 * @param val 传入的值 例如 新订单为0
 * @param nowid 组合ID用的后一部分序号，例如id="ordertype0"， botid就是"0"
 * @param numid 有多少个ID，比如订单类型下面有七项，这里则为7
 * @param formname 操作表单的名称例如 "selectform"
 * @param bottonname 全选功能 表单的ID 例如<a hideFocus="" id="selectall" class="selectall" title="全选"
 * @param checkname 复选框表单ID的名字 check_all 例如：<input id="check_all" onclick="select_ok('selectform','selectall','check_all');"
 * @param reloadtype 载入类型
 * @param eqid div ID 没有分页时候用
 * @param reloadurl 载入地址
 * @return 根据传入的参数把ajax的内容写到对应的标签上
 */
function dbfilter(botid, string, val, nowid, numid, formname, bottonname, checkname, reloadtype, eqid, reloadurl) {
    var formlist = document.getElementById(formname);
    var inputype = formlist.elements[0].value;
    var maxperpage = formlist.elements[1].value;
    var maxhit = formlist.elements[2].value;
    var nowpage = formlist.elements[3].value;
    var loadname = formlist.elements[6].value;
    var pagetextname = formlist.elements[7].value;
    var pagebottonname = formlist.elements[8].value;
    if (string.match(/\|/ig) == null) {  //是否存在 | 号
        var reStr = new RegExp(string + "=\\w*", "gi");
        var peStr = string + '=' + val;
        var str = inputype.replace(reStr, peStr)
    } else {
        var strarray = string.split('|');
        var valarray = val.split('|');
        var str = inputype;
        for (var i = 0; i < strarray.length; i++) {
            var reStr = new RegExp(strarray[i] + "=\\w*", "gi");
            var peStr = strarray[i] + '=' + valarray[i];
            str = str.replace(reStr, peStr)
        }
    }
    formlist.elements[0].value = str;  //根据参数载入的url
    var pageid = pagewindow();
    pageload(pageid, maxhit, nowpage, str, loadname, pagetextname, pagebottonname, formname);
    var classid = '';
    for (i = 0; i <= numid; i++) {
        if (i != nowid) {
            classid = classid + '#' + botid + i + ','
        }
    }
    if (reloadtype == true) {
        $("#" + eqid).load(reloadurl)
    }
    classid = classid + '#neiow';
    nowid = '#' + botid + nowid;
    $(classid).removeClass('menunoclick').addClass('menuclick');
    $(nowid).removeClass('menuclick').addClass('menunoclick');
    if (document.getElementById(checkname)) {
        select_All(false, formname, bottonname, checkname)
    }
}
function onlimit(string, val, bottonid, nowid, clearid, formname, bottonname, checkname) {
    var formlist = document.getElementById(formname);
    var inputype = formlist.elements[0].value;
    var maxperpage = formlist.elements[1].value;
    var maxhit = formlist.elements[2].value;
    var nowpage = formlist.elements[3].value;
    var loadname = formlist.elements[6].value;
    var pagetextname = formlist.elements[7].value;
    var pagebottonname = formlist.elements[8].value;
    var reStr = new RegExp("(limitkey=)\\w*(&limitclass=)\\w*", "gi");
    var peStr = '$1' + string + '$2' + val;
    var str = inputype.replace(reStr, peStr);
    formlist.elements[0].value = str;
    var pageid = pagewindow();
    pageload(pageid, maxhit, nowpage, str, loadname, pagetextname, pagebottonname, formname);
    $(clearid).removeClass('displaytrue limitdesc limitasc').addClass('displaynone');
    $(nowid).removeClass('displaynone limitdesc limitasc').addClass('displaytrue limit' + val);
    if (val == 'asc') {
        var limittype = 'desc'
    } else {
        var limittype = 'asc'
    }
    var bottnvar = "javascript:onlimit('" + string + "','" + limittype + "','" + bottonid + "','" + nowid + "','" + clearid + "','" + formname + "','" + bottonname + "','" + checkname + "')";
    $(bottonid).removeAttr("href").attr("href", bottnvar);
    if (document.getElementById(checkname)) {
        select_All(false, formname, bottonname, checkname)
    }
}
function refresh(formname, bottonname, checkname) {
    if (!document.getElementById(formname)) {
        return false
    }
    var formlist = document.getElementById(formname);
    var loadurl = formlist.elements[0].value;
    var maxperpage = formlist.elements[1].value;
    var maxhit = formlist.elements[2].value;
    var nowpage = formlist.elements[3].value;
    var loadname = formlist.elements[6].value;
    var pagetextname = formlist.elements[7].value;
    var pagebottonname = formlist.elements[8].value;
    if (document.getElementById(checkname)) {
        select_All(false, formname, bottonname, checkname)
    }
    var h = $(window).height();
    if (h == '0') {
        h = $(window.parent.document).height();
        h = h - 127
    }
    pageDimensions(h, maxperpage, maxhit, nowpage, loadurl, loadname, pagetextname, pagebottonname, formname)
}
function pageDimensions(h, maxperpage, maxhit, nowpage, loadurl, loadname, pagetextname, pagebottonname, formname) {
    var pageh = h - 110;
    var pagemax = Math.round((pageh) / 32);
    if (pagemax <= 0) {
        pagemax = maxperpage
    }
    pageload(pagemax, maxhit, nowpage, loadurl, loadname, pagetextname, pagebottonname, formname)
}
function pageload(pagemax, maxhit, nowpage, loadurl, loadname, pagetextname, pagebottonname, formname) {
    var counturl = loadurl + '&countnum=2&freshid=' + Math.random();
    $.get(counturl, 
    function(data) {
        $(this).pagination(data, {
            db_now: data,
            items_per_page: pagemax,
            num_edge_entries: 2,
            num_display_entries: maxhit,
            current_page: nowpage,
            prev_text: "上一页",
            next_text: "下一页",
            home_text: "首页",
            end_text: "尾页",
            loadname: loadname,
            pagetextname: pagetextname,
            pagebottonname: pagebottonname,
            formname: formname,
            loadurl: loadurl,
            callback: pageselectCallback
        });
        pageselectCallback(loadurl, nowpage, pagemax, data, loadname, pagetextname, formname)
    })
}
//把内容载入对应div里面
function pageselectCallback(loadurl, page_id, page_id2, countnum, loadname, pagetextname, formname) {
    var limitstard = (page_id * page_id2);
    $(loadname).load(loadurl, {
        'MinPageid': limitstard,
        'page_id': page_id,
        'MaxPerPage': page_id2
    });
    var formlist = document.getElementById(formname);
    formlist.elements[3].value = page_id;
    $(pagetextname).text("总计：" + countnum + "条记录 当前" + ((page_id * page_id2) + 1) + "-" + ((page_id * page_id2) + page_id2) + "条 每页显示" + page_id2 + "条")
}
function urlarray(str) {
    var newArray = new Array();
    var urlarrayStr = str.split("&");
    var valname = null;
    for (var i = 0; i < urlarrayStr.length; i++) {
        valname = urlarrayStr[i].split("=");
        newArray[valname[0]] = decodeURIComponent(valname[1])
    }
    return newArray
}
function submiturl(url, loadurl, runok, runno, setmsg, setmsgtitle, formname, bottonname, checkname) {
    url = url + '&freshid=' + Math.random();
    if (setmsg) {
        if (confirm(setmsgtitle)) {
            windowsdig('Loading', 'iframe:' + loadurl + '&freshid=' + Math.random(), '400px', '180px', 'iframe', false);
            $.get(url, 
            function(data) {
                closeifram();
                if (data == "true") {
                    refresh(formname, bottonname, checkname);
                    alert(runok)
                } else {
                    alert(runno)
                }
            })
        }
    } else {
        windowsdig('Loading', 'iframe:' + loadurl + '&freshid=' + Math.random(), '400px', '180px', 'iframe', false);
        $.get(url, 
        function(data) {
            closeifram();
            if (data == "true") {
                refresh(formname, bottonname, checkname);
                alert(runok)
            } else {
                var errmess = (data == "flase") ? runno: runno + data;
                alert(errmess)
            }
        })
    }
}
function selectlinkagelng(reid, reloadurl) {
    if (document.getElementById(reid)) {
        $("#" + reid).load(reloadurl + '&freshid=' + Math.random())
    }
}
function selectlinkagemodel(reid, reloadurl) {
    if (document.getElementById(reid)) {
        $("#" + reid).load(reloadurl + '&freshid=' + Math.random())
    }
}
function ondisplaymore(value, div1, div2, style1, style2, getid, classvalue, classvalue2) {
    if (value == 1 || value == 2 || value == 4) {
        $(div1).removeClass().addClass(style1);
        $(div2).removeClass().addClass(style2);
        if (value == 1) {
            $(getid).val(classvalue)
        } else {
            $(getid).val(classvalue2)
        }
    } else {
        $(div1).removeClass().addClass(style2);
        $(div2).removeClass().addClass(style1)
    }
}
function refreshurl(loadurl, formid) {
    if ($.browser.version == 6.0) {
        var h = document.body.clientHeight
    } else {
        var h = $(window).height()
    }
    var formlist = document.getElementById(formid);
    loadurl = loadurl;
    var maxperpage = formlist.elements[1].value;
    var maxhit = formlist.elements[2].value;
    var nowpage = formlist.elements[3].value;
    var loadname = formlist.elements[6].value;
    var pagetextname = formlist.elements[7].value;
    var pagebottonname = formlist.elements[8].value;
    formlist.elements[0].value = loadurl;
    pageDimensions(h, maxperpage, maxhit, nowpage, loadurl, loadname, pagetextname, pagebottonname, formid)
}
function ondisplayvalue(value, getid, classvalue, classvalue2) {
    if (value == 1) {
        $(getid).val(classvalue)
    } else {
        $(getid).val(classvalue2)
    }
}
function checktypename(dbname, value, loadurl, gettxtid, okmess, nomess, bottonname) {
    var um = document.getElementById(gettxtid);
    var nullstr = "\u8F93\u5165\u4E0D\u80FD\u4E3A\u7A7A";
    if (value == '') {
        um.innerHTML = "<font color=\"red\">" + nullstr + "</font>";
        $('#' + bottonname).attr('disabled', 'true');
        return false
    }
    $.ajax({
        type: "POST",
        url: loadurl,
        data: dbname + "=" + value,
        success: function(date) {
            if (date == "false") {
                um.innerHTML = "<font color=\"red\">" + nomess + "</font>";
                $('#' + bottonname).attr('disabled', 'true')
            } else {
                um.innerHTML = "<font color=\"#1CB521\">" + okmess + "</font>";
                $('#' + bottonname).attr('disabled', '')
            }
        }
    })
}
function checktypelngname(dbname, value, lng, regular, loadurl, gettxtid, okmess, nomess, bottonname) {
    var um = document.getElementById(gettxtid);
    var lngval = document.getElementById(lng).value;
    var nullstr = "\u8F93\u5165\u4E0D\u80FD\u4E3A\u7A7A";
    if (value == '') {
        um.innerHTML = "<font color=\"red\">" + nullstr + "</font>";
        $('#' + bottonname).attr('disabled', 'true');
        return false
    }
    if (value.match(regular) == null) {
        um.innerHTML = "<font color=\"red\">" + nomess + "</font>";
        $('#' + bottonname).attr('disabled', 'true');
        return false
    }
    $.ajax({
        type: "POST",
        url: loadurl,
        data: dbname + "=" + value + "&lng=" + lngval,
        success: function(date) {
            if (date == "false") {
                um.innerHTML = "<font color=\"red\">" + nomess + "</font>";
                $('#' + bottonname).attr('disabled', 'true')
            } else {
                um.innerHTML = "<font color=\"#1CB521\">" + okmess + "</font>";
                $('#' + bottonname).attr('disabled', '')
            }
        }
    })
}
function checktemplatecode(dbname, value, dbname2, lng, regular, loadurl, gettxtid, okmess, nomess, bottonname) {
    var um = document.getElementById(gettxtid);
    if (document.getElementById(lng)) {
        var lngval = document.getElementById(lng).value
    }
    if (value == '') {
        um.innerHTML = "<font color=\"red\">" + nomess + "</font>";
        $('#' + bottonname).attr('disabled', 'true');
        return false
    }
    if (value.match(regular) == null) {
        um.innerHTML = "<font color=\"red\">" + nomess + "</font>";
        $('#' + bottonname).attr('disabled', 'true');
        return false
    }
    $.ajax({
        type: "POST",
        url: loadurl,
        data: dbname + "=" + value + "&" + dbname2 + "=" + lngval,
        success: function(date) {
            if (date == "false") {
                um.innerHTML = "<font color=\"red\">" + nomess + "</font>";
                $('#' + bottonname).attr('disabled', 'true')
            } else {
                um.innerHTML = "<font color=\"#1CB521\">" + okmess + "</font>";
                $('#' + bottonname).attr('disabled', '')
            }
        }
    })
}
function fnupdate(linkdid) {
    var inputvalue = $(":input[name=\"linkdid\"]").val();
    var newval = inputvalue + linkdid;
    $(":input[name=\"linkdid\"]").val(newval)
}
function updatekeywords(linkdid, inputname) {
    var inputvalue = $(":input[name=\"" + inputname + "\"]").val();
    var newval = inputvalue + linkdid;
    $(":input[name=\"" + inputname + "\"]").val(newval)
}
function getminusdate(startday,endday)
{
	var fArray = startday.split('-');
	var sArray = endday.split('-');
	var fDate = new Date(fArray[0],(parseInt(fArray[1])-1),fArray[2]);
	var sDate = new Date(sArray[0],(parseInt(sArray[1])-1),sArray[2]);
	
	var t = Math.abs(fDate.getTime()-sDate.getTime());
	var days = t/(24 * 3600 * 1000);
	return days;
}
function gethasdate(startday,endday) {
	var fArray = startday.split('-');
	var sArray = endday.split('-');
	var fDate = new Date(fArray[0],(parseInt(fArray[1])-1),fArray[2]);
	var sDate = new Date(sArray[0],(parseInt(sArray[1])-1),sArray[2]);
	var t = fDate.getTime()-sDate.getTime();
	var days = t/(24 * 3600 * 1000);
	return days;
}
function checkdate(datestr) 
{ 
    var   reg=/\d{4}-\d{1,2}-\d{1,2}/ 
    if(reg.test(datestr)){return   true} 
    else{return   false} 
    var   str=f1.text.value 
    var   c_str=str.splite( "- ") 
    if(c_str[1]> 12){return   false}
    else   if(c_str[2]> 31){return   fale}
}